% Matlab file to implement class "deriv1",
% forward mode of automatic differentation, first derivatives
% Michael Reiter, Universitat Pompeu Fabra, April 2007
% Last update: -
% Feel free to use, copy and modify at your own risk;
%   this program comes with NO WARRANTY WHATSOEVER
% 
function xOut=horzcat(varargin)
  nv = length(varargin);
  for i=1:nv
    if(isa(varargin{i},'deriv1s'))
      np = nindep(varargin{i});
      break;
    end
  end
  for i=1:nv
    if(isa(varargin{i},'deriv1s'))
      vs{i} = varargin{i}.v;
      ds{i} = varargin{i}.d;
    else
      vs{i} = varargin{i};
      ds{i} = sparse(numel(vs{i}), np);
    end
  end
  xOut.v = horzcat(vs{:});
  xOut.d = vertcat(ds{:}); %vert, not horz, since second index is deriv!
  xOut=class(xOut,'deriv1s');


